/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package SoftSonic;

import Rout.GoBefore;
import org.testng.annotations.*;
import org.openqa.selenium.Keys;

public class SoftsonicMain {

    private GoBefore browser = new GoBefore();

    @BeforeMethod
    public void setUp() throws Exception {

        System.out.println("\n Run test: " + getClass().getSimpleName());
        browser.userAg = 1;

    }

    @Test
    public void ListButton() throws Exception {

        browser.curURL = "http://softsonic.net/";
        browser.clButton = "";
        browser.cssButton = "body > div.main-container > div.content > div.main-content.left > div.items-list > ul > li:nth-child(1) > div.right > a";
        browser.xpButton = "/html/body/div[1]/div[2]/div[3]/div[2]/ul/li[1]/div[3]/a";
        browser.xpFilename = "/html/body/div[1]/div[2]/div[3]/div[2]/ul/li[1]/div[1]/a";
        browser.repDir = getClass().getSimpleName();

        browser.setUp();
        browser.testRun();
        browser.lpDetect();
        browser.verFilename();
        browser.verFilePresent();

    }

    @Test
    public void softPageUpbutton() throws Exception {
        browser.curURL = "http://softsonic.net/happyland-adventures";
        browser.clButton = "download dark";
        browser.cssButton = "#down-free";
        browser.xpButton = "//*[@id=\"down-free\"]";
        browser.xpFilename = "/html/body/div[1]/div[2]/div[2]/div[1]/h1/text()";
        browser.repDir = getClass().getSimpleName();

        browser.setUp();
        browser.testRun();
        browser.lpDetect();
        browser.verFilename();
        browser.verFilePresent();

    }

    @Test
    public void softPageDownbutton() throws Exception {
        browser.curURL = "http://softsonic.net/happyland-adventures";
        browser.clButton = "";
        browser.cssButton = "body > div.main-container > div.content > div.product-content.left > div.product-info > div.product-feat.right > div.product-down.left > a";
        browser.xpButton = "/html/body/div[1]/div[2]/div[2]/div[2]/div[3]/div[2]/a";
        browser.xpFilename = "/html/body/div[1]/div[2]/div[2]/div[1]/h1/text()";
        browser.repDir = getClass().getSimpleName();

        browser.setUp();
        browser.testRun();
        browser.lpDetect();        
        browser.verFilePresent();
        browser.verFilename();

    }

    @Test
    public void upBar() throws Exception {
        browser.curURL = "http://softsonic.net/happyland-adventures";
        browser.clButton = "";
        browser.cssButton = "";
        browser.xpButton = "//*[@id=\"product-fixed\"]/div/a";
        browser.xpFilename = "/html/body/div[1]/div[2]/div[2]/div[1]/h1/text()";
        browser.repDir = getClass().getSimpleName();

        browser.setUp();
        
        browser.clicker.sendKeys(Keys.PAGE_DOWN).build().perform();
        browser.clicker.sendKeys(Keys.PAGE_DOWN).build().perform();
        browser.clicker.sendKeys(Keys.PAGE_DOWN).build().perform(); 
        
        browser.testRun();
        browser.lpDetect();
        browser.verFilename();
        browser.verFilePresent();

    }
    
        @Test
    public void downLinks() throws Exception {
        browser.curURL = "http://softsonic.net/happyland-adventures";
        browser.clButton = "";
        browser.cssButton = "body > div.main-container > div.content > div.product-content.left > div.similar-products > ul > li:nth-child(2) > div:nth-child(2) > a";
        browser.xpButton = "//html/body/div[1]/div[2]/div[2]/div[3]/ul/li[2]/div[2]/a";
        browser.xpFilename = "/html/body/div[1]/div[2]/div[2]/div[3]/ul/li[2]/div[1]/a/text()";
        browser.repDir = getClass().getSimpleName();

        browser.setUp();
        
        browser.clicker.sendKeys(Keys.PAGE_DOWN).build().perform();
        browser.clicker.sendKeys(Keys.PAGE_DOWN).build().perform();
        browser.clicker.sendKeys(Keys.PAGE_DOWN).build().perform(); 
        
        browser.testRun();
        browser.lpDetect();
        browser.verFilename();
        browser.verFilePresent();

    }

    @AfterMethod
    public void ThearsDown() {
        browser.driver.quit();

    }

}
